class Post < ActiveRecord::Base

  validates :author, :title, :context, presence: true

  validates :author ,
            length: {minimum: 2,maximum: 16}
  validates :title,
            length: {minimum: 2,maximum: 20}
  validates :context,
            length: {minimum: 1}

  belongs_to :family #一对一，可以与另一端的has_many组成多对一,外键在当前模型




  def getAll
    Post.all
  end





end
